package com.teatang.tadmin.sysuser.controller;

import com.teatang.tadmin.core.controller.BasePageController;
import com.teatang.tadmin.sysuser.service.SysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Controller
public class SysUserPageController extends BasePageController {

    @Autowired
    private SysUserService sysUserService;

    @RequiresPermissions("sys:user-page:index")
    @GetMapping("/sys-user-page/index.html")
    public String index() {
        return "sys-user/index";
    }

    @RequiresPermissions("sys:user-page:add")
    @GetMapping("/sys-user-page/add.html")
    public String add() {
        return "sys-user/add";
    }

    @RequiresPermissions("sys:user-page:edit")
    @GetMapping("/sys-user-page/edit.html/{id}")
    public String edit(@PathVariable("id") int id, Model model)
    {
        model.addAttribute("model", sysUserService.getSysUserById(id));
        return "sys-user/edit";
    }
}
